import { Table } from 'antd';
// import React from 'react';
import request from '@/http';
import All_style from '../../index.less';
import React, { useState } from 'react';
const columns = [
  {
    title: '项目名称',
    dataIndex: 'courseName',
    key: 'courseName',
  },
  {
    title: '小组名称',
    dataIndex: 'teamName',
    key: 'teamName',
  },
  {
    title: '小组成员',
    dataIndex: 'teamStudents',
    key: 'teamStudents',
    render: (text: any, row: any) => {
      return (
        <>
          {row?.teamStudents?.map((item: any, index: number) => {
            return (
              <span key={index}>
                {item.studentName}
                <br />{' '}
              </span>
            );
          })}
        </>
      );
    },
  },
  {
    title: '项目角色',
    dataIndex: 'teamStudents',
    key: 'teamStudents',
    render: (text: any, row: any) => {
      return (
        <>
          {row?.teamStudents?.map((item: any, index: number) => {
            return (
              <span key={index}>
                {item.studentRole} <br />
              </span>
            );
          })}
        </>
      );
    },
  },
  {
    title: '组长',
    dataIndex: 'teamStudents',
    key: 'teamStudents',
    render: (text: any, row: any) => {
      return (
        <>
          {row?.teamStudents?.map((item: any, index: number) => {
            return (
              <span key={index}>
                {item.teamLeader === 1 ? '√' : ' '} <br />
              </span>
            );
          })}
        </>
      );
    },
  },
  {
    title: '标准学时',
    dataIndex: 'teamStudents',
    key: 'teamStudents',
    render: (text: any, row: any) => {
      return (
        <>
          {row?.teamStudents?.map((item: any, index: number) => {
            return (
              <span key={index}>
                {item.standardHours}
                <br />{' '}
              </span>
            );
          })}
        </>
      );
    },
  },
  {
    title: '大课学时',
    dataIndex: 'teamStudents',
    key: 'teamStudents',
    render: (text: any, row: any) => {
      return (
        <>
          {row?.teamStudents?.map((item: any, index: number) => {
            return (
              <span key={index}>
                {item.bigclassHours}
                <br />{' '}
              </span>
            );
          })}
        </>
      );
    },
  },
  {
    title: '自习学时',
    dataIndex: 'teamStudents',
    key: 'teamStudents',
    render: (text: any, row: any) => {
      return (
        <>
          {row?.teamStudents?.map((item: any, index: number) => {
            return (
              <span key={index}>
                {item.selfstudeyHours}
                <br />{' '}
              </span>
            );
          })}
        </>
      );
    },
  },
  {
    title: '联系电话',
    dataIndex: 'teamStudents',
    key: 'teamStudents',
    render: (text: any, row: any) => {
      return (
        <>
          {row?.teamStudents?.map((item: any, index: number) => {
            return (
              <span key={index}>
                {item.studentTell}
                <br />{' '}
              </span>
            );
          })}
        </>
      );
    },
  },
];
const dataOld = [
  {
    teamID: 2,
    courseName: '在线考试系统',
    teamName: '至尊',
    teamStudents: [
      { studentName: '', studentRole: '', teamLeader: null, studentTell: '' },
    ],
  },
];

const Member = () => {
  const [data, setData] = React.useState(dataOld);
  const loadData = async () => {
    const result: any = await request.get('/user/_s/queryTrainingTeamInfo');
    console.log(result.date);
    if (result.code) {
      setData(result.date);
    }
  };

  React.useEffect(() => {
    loadData();
  }, []);

  return (
    <>
      <Table columns={columns} dataSource={data} className={All_style.table2} />
    </>
  );
};
export default Member;
